<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>享送小哥</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav aui-bar-light u-aui-bar" id="header">
        <a class="aui-pull-left aui-btn" onclick="api.closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title u-aui-title">附近自由快递人</div>
    </header>
    <!--js-->
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/vue.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>

    <script type="text/javascript">
        apiready = function() {

            var near = api.pageParam.near || [],
                location = api.pageParam.location || {
                    lon: 0,
                    lat: 0
                };


            var statusBarPos = app.statusBar.pos();
            var headerPos = app.pos('header');

            api.addEventListener({
                name: 'viewappear'
            }, function(ret, err) {
                var map = api.require('bMap');

                map.open({
                    rect: {
                        x: 0,
                        y: statusBarPos.h + headerPos.h,
                        w: api.winWidth,
                        h: api.winHeight - statusBarPos.h - headerPos.h
                    },
                    center: location,
                    zoomLevel: 15,
                    showUserLocation: true,
                    fixedOn: api.frameName,
                    fixed: true
                }, function(ret, err) {

                    if (ret.status) {

                        var lonlat = [];
                        for (var i = 0; i < near.length; i++) {
                            lonlat.push({
                                id: i,
                                lon: near[i].lng,
                                lat: near[i].lat
                            });
                        }

                        // console.log(JSON.stringify(lonlat));

                        map.addAnnotations({
                            annotations: lonlat,
                            icon: 'widget://images/qs.png',
                            draggable: false
                        }, function(ret) {

                        });

                        // alert('地图打开成功');
                    }
                });
            });
        }
    </script>
</body>

</html>
